import web
from config import settings
from app import model
from datetime import datetime
import os
#public


#action
class index:
    def GET(self):
        i = web.input(page=1,name="")
        links=model.link.list(i.page)
        return admin_render('link/index.html',links=links,ctx=i)

class edit:
    def GET(self):
        i=web.input(lid=0)
        
        if i.lid:
           i=model.link.getLinkById(int(i.lid))
       
        return admin_render('link/edit.html',link=i)

    def POST(self):
        i=web.input(lid=0,url="",intro="",sort=0,is_check=0,created=datetime.now())

        model.link.edit(lid,i)
        raise web.seeother('/link')
